<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%book}}".
 *
 * @property integer $id
 * @property integer $author_id
 * @property string $author_name
 * @property string $category_name
 * @property integer $category_id
 * @property string $name
 * @property string $cover
 * @property string $desc
 * @property integer $over
 * @property integer $status
 * @property integer $create_time
 * @property integer $nub
 */
class Book extends Common
{
    const STATUS_OK = 1;
    const STATUS_DOWN = 0;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%book}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['author_id', 'author_name', 'category_id', 'name', 'create_time', 'nub'], 'required'],
            [['author_id', 'category_id', 'over', 'status', 'create_time', 'nub'], 'integer'],
            [['desc'], 'string'],
            [['author_name', 'name'], 'string', 'max' => 50],
            [['category_name'], 'string', 'max' => 30],
            [['cover'], 'string', 'max' => 150],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'author_id' => '作者ID',
            'author_name' => '作者名字',
            'category_name' => '分类名称',
            'category_id' => '分类ID',
            'name' => '书名字',
            'cover' => '封面',
            'desc' => '描述',
            'over' => '0:连载 1：已完结',
            'status' => '1:正常 0：下架',
            'create_time' => '入库时间',
            'nub' => '阅读人数',
        ];
    }
}
